home *** CD-ROM | disk | FTP | other *** search
- Path: jupiter.planet.net!usenet
- From: Chris Kemp <chrisk@paladn.com>
- Newsgroups: comp.lang.c
- Subject: kbhit and getche loop
- Date: 4 Feb 1996 01:14:23 GMT
- Organization: Paladin Consultants, Inc.
- Message-ID: <4f119f$7e7@jupiter.planet.net>
- NNTP-Posting-Host: denv11.planet.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.2N (Windows; I; 32bit)
-
- I have the following code which I want to take characters from the stdin, and
- append them onto a commandstring. Inbetween processing the characters, the
- computer has to ckeck some things, but if it gets a character, I want to append it
- onto the commandstring. When getche gets a {return}, I want the commandstring to
- be processed.
-
-
- I think my problem is in processing the ch character, or perhaps comparing it to
- '/n'. Also, I couldn't concatenate ch directly onto commandstring, because ch is
- an integer, and strcat wants a const char * in the second position.
-
-
- If anyone has some thoughts about hot to do this, I'd sure would like a good
- suggestion.
-
- TIA
-
- do { // master command loop
-
- while (!kbhit()){
- // get actual positions
-
- gisilent=TRUE;
- for (i=0;i<=MAXAXIS;i++){
- *actualposition[i]=rcp(i);
- }
- gisilent=FALSE;
- }
-
- int ch;
- char *charget;
- ch=getche();
- *charget=ch;
- strcat(commandstring,charget);
-
- if (ch=='/n') {
- parse(commandstring, delimiter); //separate it into tokens
- store in parsedarray[MAXWORDS][SIZE]
- processcommandincommandstring();
- }
- } while (0 EQ 0); //infinite loop
-
-